package com.tjvib.util.retrofit;

import com.tjvib.Constants;

/**
 * 针对不同错误码编写不同逻辑
 */
public class ApiException extends RuntimeException {


    private int mErrorCode;

    public ApiException(int errorCode, String errorMessage) {
        super(errorMessage);
        mErrorCode = errorCode;
    }

    /**
     * 判断是否是token失效
     *
     * @return 失效返回true, 否则返回false;
     */
    public boolean isTokenExpried() {
        return mErrorCode == Constants.TOKEN_INVALID;
    }

    /**
     * 判断是否失败
     *
     * @return 失效返回true, 否则返回false;
     */
    public boolean isFailed() {
        return mErrorCode == Constants.FAIL_INVALID;
    }
}

